package com.mkz.jbpm.controller;

import java.util.List;

import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import lombok.AllArgsConstructor;

@RestController
@AllArgsConstructor
public class ActiRepositoryController {
    private final IdentityService identityService;
	//7、查询属于组group1的用户
  	@RequestMapping("/queryUserListByGroup")
  	public void queryUserListByGroup(){
  		
  	    //查询属于组group1的用户
  		List<User> usersInGroup = identityService.createUserQuery().memberOfGroup("group1").list();
  		for (User user : usersInGroup) {
			System.out.println(user.getFirstName());
		}
  		 
  	}
  //8、查询user1所属于的组
  	@RequestMapping("/queryGroupListByUser")
  	public void queryGroupListByUser(){
  		
  	    //查询user1所属于的组
  		List<Group> groupsForUser = identityService.createGroupQuery().groupMember("user1").list();
  		for (Group group : groupsForUser) {
			System.out.println(group.getName());
		}
  	}
}
